package top.itaso.lib.compiler;

import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Messager;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;

/**
 * @Description: 注解处理程序
 * @Author itsdf07
 * @E-Mail 923255742@qq.com
 * @Gitee https://gitee.com/itsdf07
 * @Date 2023/12/2
 */
//2、进行注册之后才可用，类似Android的Activity等在AndroidManifest的注册，
// 固定目录格式：resources/META-INF.services/javax.annotation.processing.Processor 内注册全类名：top.itaso.lib.inject.InjectItaso

//3、限制只接收的注解
@SupportedAnnotationTypes("top.itaso.lib.inject.InjectItaso")
public class InjectCompiler extends AbstractProcessor {
    //1、javac 编译时进行实例化，然后调用process方法
    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        for (TypeElement typeElement : annotations) {//解决调用三次问题：只有第一次注解参数不为空
            Messager messager = processingEnv.getMessager();
            messager.printMessage(Diagnostic.Kind.NOTE, "InjectCompiler===============================");
        }

        return false;
    }
}
